﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;


namespace Appcode
{
  public  class UsersDAL
    {
        private MyConnection DB_Con = new MyConnection();

        public UserLogin CheckLogin(String account, String password)
        {
            try
            {
                SqlConnection con = DB_Con.openConnection();
                SqlCommand com = new SqlCommand("getLogin", con);
                com.Parameters.AddWithValue("@accname", account);
                com.Parameters.AddWithValue("@password", password);
                com.CommandType = System.Data.CommandType.StoredProcedure;
                SqlDataReader reader = com.ExecuteReader();
                UserLogin user = new UserLogin();
                while (reader.Read())
                {
                    user.UserID = reader.GetInt32(0);
                    user.UserName = reader.GetString(1);
                    user.UserAccount = reader.GetString(2);
                    user.UserPassWord = reader.GetString(3);
                    user.UserCreateDate = reader.GetDateTime(4);
                }
                return user;
            }
            catch (Exception)
            {
                return null;
            }
        }
    }
}
